<template>
  <div>
    <h2>这是TodoList组件</h2>
  </div>
  <div class="main-box">
    <h1>状态管理测试界面</h1>
    <h1>状态count：{{ homeStore.count }}</h1>
    <!-- <h1>状态curCount：{{ calculateCount }}</h1>
    <van-button @click="initCount">归零</van-button> -->
    <van-button type="success" @click="changeCount">计数</van-button>
    <van-button type="danger" @click="randomCount">随机</van-button>
    <van-button type="danger" @click="getData">获取数据</van-button>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { useHomeStore } from "../store/modules/home";
import { login, getUserInfo } from "../api/index";
const username = ref("");
const password = ref("");
async function getData() {
  const res = await login({
    username: username.value,
    password: password.value,
  });
  console.log(res);
}
const homeStore = useHomeStore();

const changeCount = () => {
  homeStore.count++;
};

const randomCount = () => {
  const num = Math.random() * 100;
  homeStore.updatecount(Math.floor(num));
};
</script>

<style scoped></style>
